package com.sun.weekend.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sun.weekend.R;
import com.sun.weekend.base.BaseFragment;
import com.sun.weekend.beans.BundleBean;
import com.sun.weekend.util.Go2Util;

/**
 * @author sunleilei
 */

public class UserCenterFragment extends BaseFragment{

    ImageView user_icon;
    TextView user_name;
    ImageView user_bg;
    public static UserCenterFragment newInstance() {

        Bundle args = new Bundle();
        UserCenterFragment fragment = new UserCenterFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public void onStart() {
        super.onStart();
        if (userBean != null) {
            user_name.setText(userBean.getUsername());
            if (userBean.getAvstar() != null) {
                Glide.with(this).load(userBean.getAvstar().getFileUrl()).into(user_bg);
                Glide.with(this).load(userBean.getAvstar().getFileUrl()).into(user_icon);
            }
        }

    }

    @Override
    protected int getLayoutId() {
        return R.layout.usercenter_fragment;
    }

    @Override
    protected void findViews(View view) {
        user_icon = (ImageView) view.findViewById(R.id.user_icon);
        user_name = (TextView) view.findViewById(R.id.user_name);
        user_bg = (ImageView) view.findViewById(R.id.user_bg);
        user_icon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BundleBean bean = new BundleBean();
                bean.setSign("UserCenterEditInfo");
                Go2Util.go2Module(mContext,bean);
            }
        });
    }
}
